package com.wteam.until;

import com.wteam.framework.common.vo.ResultMessage;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.checkerframework.checker.units.qual.A;
import org.checkerframework.common.value.qual.ArrayLen;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result<T> {
    private static final long serialVersionUID = 1L;

    /**
     * 返回状态码
     */
    private Integer code;
    /**
     * 消息
     */
    private String message;
    /**
     * 结果对象
     */
    private T data;

    /**
     * 时间戳
     */
    private long timestamp = System.currentTimeMillis();

    public Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    public static Result SuccessAndTime(Integer code, String message, Object data) {
        return new Result(code, message, data);
    }

    public static Result success(Integer code, String message, Object data) {
        return new Result(code, message, data);
    }

    public static Result success() {
        return new Result(200, "success", null);
    }

    //查询 成功响应
    public static Result success(Object data) {
        return new Result(200, "success", data);
    }

    //失败响应
    public static Result error(String msg) {
        return new Result(0, msg, null);
    }

    public static Result error(Integer code,String msg) {
        return new Result(code, msg, null);
    }

}
